<!--包含头部文件-->
{include file="public/header" /}
<body>
<article class="page-container">
    <form class="form form-horizontal" action="" method="post" id="form-admin-edit">
        <input name="admin_id" id="admin_id" type="hidden" value="{$admin_info.id}" />
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>登录名：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="text" class="input-text" value="{$admin_info.admin_username}" placeholder="" id="admin_username" name="admin_username"/>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>真实姓名：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="text" class="input-text" value="{$admin_info.admin_realname}" placeholder="" id="admin_realname" name="admin_realname"/>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">密码：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="text" class="input-text" value="" placeholder="输入登录密码，为空不更改" id="admin_pwd" name="admin_pwd"/>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="tel" class="input-text" placeholder="" value="{$admin_info.admin_tel}" name="admin_tel" id="admin_tel"/>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="text" class="input-text" placeholder="" value="{$admin_info.admin_email}" name="admin_email" id="admin_email"/>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>所属角色：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <span class="select-box">
                    <select name="group_id" class="select valid">
                    <option value="0">请选择管理员角色</option>
                        {volist name="auth_group" id="vo"}
                            <option value="{$vo.id}"  {if condition="$vo['id'] eq $auth_group_access"}selected{/if}>{$vo.title}</option>
                        {/volist}
                </select>
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否已启用：</label>
            <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                <div class="radio-box">
                    <input name="admin_open" value="1" type="radio" id="status-1" {if condition="$admin_info['admin_open'] eq 1"}checked{/if}>
                    <label for="status-1">启用</label>
                </div>
                <div class="radio-box">
                    <input type="radio" value="0" id="status-2" name="admin_open" {if condition="$admin_info['admin_open'] eq 0"}checked{/if}>
                    <label for="status-2">关闭</label>
                </div>
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;"/>
            </div>
        </div>
    </form>
</article>

<!--包含footer文件-->
{include file="public/footer" /}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script>

<script type="text/javascript">


    /*添加管理员*/
    function admin_add(title, url, w, h) {
        layer_show(title, url, w, h);
    }

    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-admin-edit").validate({
            rules:{
                admin_username:{
                    required:true,
                },
                admin_realname:{
                    required:true,
                },
                admin_tel:{
                    required:true,
                    isMobile:true,
                },
                admin_email:{
                    required:true,
                },

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var arr = $('#form-admin-edit').serialize();
                $.ajax({
                    url:"{:url('admin/admin_edit')}",
                    type:"post",
                    data:arr,
                    dataType:"json",
                    success:function (data) {
                        if (data.code == 200){
                            layer.alert('修改成功',{
                                skin: 'layui-layer-molv' //样式类名 自定义样式
                                ,closeBtn: 0  // 是否显示关闭按钮
                                ,anim: 1 //动画类型
                                ,btn: '确认'//按钮
                                ,icon: 6  // icon
                                ,yes:function(){
                                    layer.closeAll();
                                    parent.location.reload();
                                }
                            })
                        }else {
                            layer.alert('修改失败'+data.msg+'',{
                                skin: 'layui-layer-molv' //样式类名 自定义样式
                                ,closeBtn: 0  // 是否显示关闭按钮
                                ,anim: 1 //动画类型
                                ,btn: '确认'//按钮
                                ,icon: 6  // icon
                                ,yes:function(){
                                    layer.closeAll();
                                    parent.location.reload();
                                }
                            })
                        }

                    },
                    error:function () {
                        alert("添加失败")
                        return false;
                    }
                })

            }
        });

    });
</script>

<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>